// pages/indexdetail/indexdetail.js
// import Dialog from 'path/to/@vant/weapp/dist/dialog/dialog';
var app = getApp();
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		data:{},
		message:'',
		autosize:{
			maxHeight:100,
			minHeight:50
		},
		showDisclaimers:false,
		showDisclaimers1:false,
		showDisclaimers2:false,
	},
	handleMakePhoneCall(event){
		var phone = event.currentTarget.dataset.phone;
		wx.showModal({
			title: '温馨提示',
			content: '是否拨打该招聘电话？',
			success (res) {
				if (res.confirm) {
					wx.makePhoneCall({
						phoneNumber: phone
					});
				}else if (res.cancel) {
				}
			}
		});
	},
	onheaderClickLeft() {
		wx.navigateBack({})
	},
	Disclaimers(){
		this.setData({showDisclaimers:true})
	},
	CloseDisclaimers(){
		this.setData({showDisclaimers:false})
	},
	confiryDisclaimers(){
		this.setData({showDisclaimers:false})
	},
	Disclaimers1(){
		this.setData({showDisclaimers1:true})
	},
	CloseDisclaimers1(){
		this.setData({showDisclaimers1:false})
	},
	confiryDisclaimers1(){
		this.setData({showDisclaimers1:false})
	},
	handleSkipReport(){
		this.setData({showDisclaimers2:true})
	},
	CloseDisclaimers2(){
		this.setData({showDisclaimers2:false})
	},
	confiryDisclaimers2(){
		this.setData({showDisclaimers2:false})
	},
	handleBackIndex(){
		wx.navigateBack({})
	},
	GetData(id){
		if(!id){
			wx.showToast({
				title: '参数错误',
				icon: 'error',
				duration: 2000
			})
			setTimeout(function(){
				wx.navigateBack({})
			},2000);
			return false;
		}
		wx.showLoading({
			title: '加载中...',
			mask:true
		});
		wx.request({
			url: 'https://www.grabinter.com/Personnotes/showpersonnotes',
			method: 'POST',
			header: {
				"Content-Type": 'application/x-www-form-urlencoded'
			},
			data: {
				id:id,
				token:wx.getStorageSync('token'),
			},
			success: json => {
				var data = json.data.data;
				var dotype = '';
				if(parseInt(data.dotype)==0){
					dotype = '替班长期都干';
				}else if(parseInt(data.dotype)==1){
					dotype = '只干替班';
				}else{
					dotype = '只干长期';
				}
				data.dotype = dotype;
				
				var shebeitext = '';
				for(var i in app.globalData.shebei){
					for(var x in app.globalData.shebei[i].children){
						const itgem = app.globalData.shebei[i].children[x];
						if(itgem.sid == data.sid){
							shebeitext = itgem.text
						}
					}
				}
				data.sid = shebeitext;
				var op = '';
				if(parseInt(data.op)==2){
					op = '反手';
				}else if(parseInt(data.op)==1){
					op = '正手';
				}else{
					op = '正反都可';
				}
				data.op = op;
				data.pskill = data.pskill.split(',');
				this.setData({
					data:data
				})
				wx.hideLoading();
			}
		});
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		if(!parseInt(options.id)){
			wx.showToast({
				title: '参数错误',
				icon: 'error',
				duration: 2000,
			});
			setTimeout(()=>{
				wx.navigateBack({})
			},2000)
			return false;
		}
		this.GetData(options.id);
	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function(options) {
		
	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {

	}
})
